home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
TCL1
/
MIDI_MAN
/
CMIDIINP.C
< prev
next >
Wrap
Text File
|
1992-03-07
|
3KB
|
92 lines
//--- CMIDIInputPort.c -----------------------------------------------------------------
// Copyright ⌐ Paul Ferguson, 1990, 1991, 1992. All rights reserved.
//
// Superclass: CDataPort
// Subclasses: None
//
// Description:
// CMIDIInputPort.c defines a MIDI Manager port object.
//
// For use with THINK C 5.0, the accompanying THINK Class Library (TCL), and MIDI
// Manager 2.0. Refer to the accompanying Microsoft Word document for complete
// details about MIDI Manager objects.
//
// If you have comments or questions about this code, you can reach me on
// CompuServe at 70441,3055.
//
//--------------------------------------------------------------------------------------
//---- NOTE --- NOTE --- NOTE --- NOTE --- NOTE --- NOTE --- NOTE --- NOTE --- NOTE ----
//--------------------------------------------------------------------------------------
// If you are not familiar with programming the Apple MIDI Manager, refer to the
// "MIDI Management Tools" Version 2.0, available from APDA. You MUST have the
// software (MIDI.H and the library) from this package in order to use these objects.
// It will not work without this.
//--------------------------------------------------------------------------------------
// REVISION HISTORY:
// August ??, 1990 - Original release (1.0).
// November 5, 1990 - Added checks for midiMgrVer to most methods.
// August 1991 - updated for THINK C 5.0 as version 2.0
//--------------------------------------------------------------------------------------
#include "CMIDIInputPort.h" // This code's header file
extern OSType gSignature; // Used to register client
#define noClient ' ' // The UnClient
extern CMIDIClient * gMIDIClient;
OSErr CMIDIInputPort::IMIDIInputPort(StringPtr theName,
OSType thePortID,
Boolean theVisibleFlag,
CMIDITimePort * theTimePort,
long theOffset,
short theBufSize,
ProcPtr theReadHook)
{
MIDIPortParams portParams; // MIDI Mgr Init data structure
register MIDIPortParams * portPPtr = &portParams;
portPPtr->portID = thePortID;
portPPtr->portType = midiPortTypeInput;
if ( (theVisibleFlag == FALSE) && (itsVersion >= 0x0200) ) // Invisible input port, in 2.x
portPPtr->portType |= midiPortInvisible;
portPPtr->timeBase = theTimePort ? theTimePort->GetRefNum() : 0;
portPPtr->offsetTime = theOffset;
portPPtr->readHook = (Ptr) theReadHook;
portPPtr->refCon = SetCurrentA5();
BlockMove(theName, portPPtr->name, theName[0]+1);
return IMIDIPort(portPPtr, theBufSize);
}
void CMIDIInputPort::Flush(void)
{
if (itsVersion)
MIDIFlush(itsRefNum);
}
ProcPtr CMIDIInputPort::GetReadHook(void)
{
return itsVersion ? MIDIGetReadHook(itsRefNum) : 0;
}
void CMIDIInputPort::SetReadHook(ProcPtr theReadHook)
{
if (itsVersion)
MIDISetReadHook(itsRefNum, theReadHook);
}
void CMIDIInputPort::Poll(long offsetTime)
{
if (itsVersion)
MIDIPoll(itsRefNum, offsetTime);
}
void CMIDIInputPort::DiscardPacket(MIDIPacketPtr thePacket)
{
if (itsVersion >= 0x0200) // Only valid on MM 2.0 or later!
MIDIDiscardPacket(itsRefNum, thePacket);
}
// end of CMIDIInputPort.c